﻿using System.Collections.Generic;
using UnityEngine;

public class SoldierChaseState : ISoldierState
{
    public SoldierChaseState(SoldierFSMSystem fsm,ICharacter character) : base(fsm,character)
    {
        mStateId = SoldierStateId.Chase;
    }

    public override void Reasoning(List<ICharacter> targets)
    {
        if (targets == null || targets.Count == 0)
        {
            mFSM.PerformTransition(SoldierTransition.NoEnemy);
            return;
        }

        float distance = Vector3.Distance(targets[0].Position, mCharacter.Position);
        if (distance < mCharacter.AtkRange)
        {
            mFSM.PerformTransition(SoldierTransition.CanAttack);
        }
    }

    public override void Actioning(List<ICharacter> targets)
    {
        if (targets != null && targets.Count > 0)
        {
            mCharacter.MoveTo(targets[0].Position);
        }
    }
}